package com.wcy.bysj.controller;

import com.wcy.bysj.common.MyException;
import com.wcy.bysj.common.Result;
import com.wcy.bysj.common.ResultEnum;
import com.wcy.bysj.entity.Admin;
import com.wcy.bysj.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/changeAdminPwd")
    @ResponseBody
    public Result changeAdminPwd(@RequestBody Admin admin) {
        try {
            return adminService.changeAdminPwd(admin);
        } catch (MyException me) {
            me.printStackTrace();
            return Result.error(ResultEnum.ERROR.getCode(),"修改失败");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(ResultEnum.ERROR.getCode(),"修改失败");
        }
    }

}
